<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="{$Assets}layui/css/layui.css">
    <style type="text/css">
.layui-table-body{
    overflow: hidden;
}
    </style>
</head>
<body>
    <div style="height: 50px;line-height: 50px;background: #fff;padding-left: 20px;font-size: 20px;font-family: microsoft yahei;margin-bottom: 10px;">
                
                <a href="javascript:void(0)" id="layerDemo" style="color: #333;font-family: microsoft yahei;float: right;margin-right: 25px;font-size: 14px;">{$user}
                    <button data-method="confirmTrans" class="layui-btn" style="background-color: #009688;">退出</button>
                </a>
    </div>


<div class="layui-btn-group demoTable" style="margin-left: 15px;">
    <button class="layui-btn" data-type="adduser"></button>
    <button class="layui-btn layui-btn-danger" data-type="delxz"></button>
</div>
<div style="width: 98%;margin:0 auto;">
<table class="layui-table" lay-data="{ url:'userall', page:true,limit:{$config_limit},limits:{$config_limits}, id:'user'}" lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
        <th lay-data="{field:'ID', width:100, sort: true,}">ID</th>
        <th lay-data="{field:'UserName', width:130}">/th>
        <th lay-data="{field:'type',width:130}"></th>
        <th lay-data=""></th>
        <!--<th lay-data="{field:'ChangePass', width:120}">/th>-->
        
        <th lay-data="{width:200, align:'center', toolbar: '#barDemo'}"></th>
    </tr>
    </thead>
</table>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit"></a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"></a>
</script>



<script src="{$Assets}layui/layui.js?t=1515376178709"></script>

<script>
    layui.use('table', function(){
        var table = layui.table;
        //
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        //
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID+ data.CarID + ' /br>');
            } else if(obj.event === 'del'){
                layer.confirm('', function(index){

                    $.ajax({
                        type:"POST",
                        url: "deluser",
                        data:{userid:data.UserID},
                        dataType:"json",

                        success:function(datas){
                            //alert(sdata);
                            //layer.msg(datas);

                            if(datas=='1'){
                                layer.msg('!');
                                setTimeout(function(){  //  setTimeout2000
                                    self.location='/index.php/admin/user/index.html';
                                },500);
                            }else{
                                layer.msg('!');
                                setTimeout(function(){  //  setTimeout2000
                                    self.location='/index.php/admin/user/index.html';
                                },1000);
                            }
                        }
                    });

                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                //layer.alert('<br>'+ JSON.stringify(data));
                self.location='edituser.html?userid='+data.UserID;
            }
        });

        var $ = layui.$, active = {
            delxz: function(){ //
                var checkStatus = table.checkStatus('user')
                    ,data = checkStatus.data;
                var deldatas=JSON.stringify(data);
                $.ajax({
                    type:"POST",
                    url: "delusers",
                    data:{num:deldatas},
                    dataType:"text",
                    success:function(datas){
                        //layer.close(index);
                        //alert(datas);
                        layer.msg(');
                        setTimeout(function(){  //  setTimeout2000
                            window.location.reload();//
                        },1000);
                    }
                });
            },
            adduser: function () {
                self.location='adduser';
            }

        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
<script>
    layui.use('layer', function(){ //layer
        var $ = layui.jquery, layer = layui.layer; //layer

        //
        var active = {
            confirmTrans: function(){

                $.ajax({
                    type:"POST",
                    url: "../index/loginout",
                    dataType:"text",
                    success:function(datas){
                        //layer.msg(datas);
                        if(datas==1){
                            layer.msg('');
                            setTimeout(parent.location.reload(),1000);
                        }
                    }
                });

            }
        };

        $('#layerDemo .layui-btn').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });

    });
</script>
{include file="public/footer"/}
</body>
</html>
